import 'package:flutter/material.dart';
import 'package:spring_fairy/model/mood_track_point.dart';
import 'package:spring_fairy/model/mood_type.dart';
import 'package:spring_fairy/model/store.dart';
import 'package:spring_fairy/pages/record_point_list_page.dart';
import 'package:spring_fairy/widget/marked_point_card.dart';
import 'package:spring_fairy/widget/mood_widget.dart';
///标记点简略信息

class PointSimpleCard extends StatefulWidget {
  final MoodTrackPoint point;

  const PointSimpleCard({super.key,required this.point});

  @override
  State<PointSimpleCard> createState() => _PointSimpleCardState();
}

class _PointSimpleCardState extends State<PointSimpleCard> {
  late MoodType _moodType;

  @override
  void initState() {
    super.initState();
    _moodType = Store.moodTypes().firstWhere((e) => e.id == widget.point.moodTypeId);
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
          return Scaffold(
            body: RecordPointListPage(track: Store.currentMoodTrack!,points: Store.getPoints().toList(),),
            appBar: AppBar(),
          );
        }));
      },
      child: Card(
        margin: EdgeInsets.symmetric(horizontal: 12, vertical: 6),
        elevation: 4,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
        child: Column(
          children: [
            Padding(
              padding: const EdgeInsets.only(top: 16),
              child: MoodWidget.list.firstWhere((e) => e.name == _moodType.name!).lottie
            ),
            Padding(padding: EdgeInsets.only(top: 32),
            child: Text(
              widget.point.description ?? '',
              maxLines: 3,
              style: TextStyle(
                fontSize: 24
              ),
            ),)
          ],
        ),
      ),
    );
  }
}
